#include <avz.h>
#include "helium/helium_helper_se.h"
#include "SimpleAvZ/lib.h"

using namespace AvZ;

void Script()
{
    SeedSlot(10);                                     // 卡槽数
    OpenMultipleEffective('Q', MAIN_UI_OR_FIGHT_UI); // 反复重开
    SetAdvancedPauseKey('Z');                        // 高级暂停
    SetSkipTickKey('S', 9);                          // 跳帧
    SetSkipTickKey('D', 19);
    SetErrorMode(NONE);
    ClearFog();
    
    SetZombies_AllType(FE);
    SelectCards({
        ICE,         // I
        M_ICE,       // I'
        DOOM,        // N
        CHERRY,      // A
        JALAPENO,    // A'
        LILY,        // 叶
        PUFF,        // c
        SUN,         // c
        SCAREDY,     // c
        POT,         // c
    });

    MaidOn();

    for(auto wave:waves(1)){
        // PPDD 601
        PP(359);
        DD(after(110),7.8125);
        M_I(601,1,4);
    }

    for(auto wave:waves(2)){
        // IPP-B-PPDD 1799
        DD(433,7.4125);
        C(1599-414-2,until(1266),PUFF,2,9);
        B(1599-414,3,8.1625);
        PP(1599,8.425);
        DD(after(215),7.4);
    }

    for(auto wave:waves(3,7,14,18)){
        // N(A')AD 678
        N(478,{{3,8},{3,9},{4,8}});
        A(after(227),1,4);
        D(478+107,5,7.4125);

        C(478,keep(207),{PUFF,SCAREDY,POT},{2,5,6},9);

        if(wave == 7) J(478,6,7);
        else if(wave == 14) J(478,1,7);

        EnsureExist({{POGO_ZOMBIE,1},{DIGGER_ZOMBIE,1}});
    }

    for(auto wave:waves(4,8,15)){
        // PPdd 731
        PP(531,8.4);
        DD(after(225),4.025);
        if(wave == 8) C(552,until(731),{PUFF,SUN,SCAREDY,POT},{1,2,5,6},9);
    }

    for(auto wave:waves(5,12,16)){
        // IPP-B-PPDD 1840
        I(0,1,4);
        DD(551,7.0625);
        C(1640-414-2,until(1266),PUFF,2,9);
        B(1640-414,3,8.1125);
        PP(1640,8.4125);
        DD(after(226),7.3375);

        M_I(1840+11,1,4);
    }

    for(auto wave:waves(6,13,17)){
        // I'PP-B-PPDD 1841
        DD(639,6.8125);
        C(1641-414-2,until(1255),PUFF,2,9);
        B(1641-414,3,8.1);
        PP(1641,8.4);
        DD(after(219),7.3125);
    }

    for(auto wave:waves(9)){
        // IPP-B-PPDDDD…
        I(0,1,4);
        DD(551,7.0625);
        C(1654+75-414-2,keep(100),{PUFF,SUN,SCAREDY,POT},{1,2,5,6},9);
        B(1654+75-414,3,8.1);
        DD(1654+75,8.275);
        DD(after(212),8.4875);
        DD(after(150),8.4875);

        P(2656,3,8.5);
        P(2656+619,5,7.5);
        //P(2656+619,5,8.5);

        P(4300,1,8);

        EnsureExist({{GIGA,1,2,5,6},{POGO_ZOMBIE,1}});
    }

    for(auto wave:waves(10)){
        // NSSAd 601
        PP(225);
        N(after(105),4,9);
        A(after(107),1,9);
        D(after(-107+235),5,3.5);
    }

    for(auto wave:waves(11)){
        // PPDD 620
        PP(420,8.575);
        DD(after(107),7.55);
    }

    for(auto wave:waves(19)){
        // PPdd-I-PPDD
        PP(531,8.4);
        DD(after(225),4.25);

        I(531+200,1,4);//懒得算极限时间了
        PP(1595-220,8.5);
        DD(1595,8.5);

        P(2056+125+5,3,7.5);
        P(2600,5,7.5);

        P(4300,1,8);

        EnsureExist({GIGA,1,2,5,6});
    }

    for (auto wave : waves(20))
    {
        MaidMove(-200);
        MaidOn(2500);

        P(251,4,7.5875);
        P(394,4,3.5);
        PP(341);
        DD(after(120),8.8);
        DD(after(110),8.8);
        P(now,1,9);
        P(now,5,9);

        PP(5500,8);
    }
}